package com.group7.mall.convert;

import com.group7.mall.dto.*;
import com.group7.mall.entity.TbGoods;
import com.group7.mall.entity.TbGoodsImage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface GoodsConverter {

    GoodsConverter INSTANCE = Mappers.getMapper(GoodsConverter.class);

    @Mapping(source = "brand", target = "goodsBrand")
    @Mapping(source = "goodsInfo", target = "goodsIntroduction")
    @Mapping(source = "minPrice", target = "lowestPrice")
    GoodsPreviewDto convertTbGoodsToGoodsPreviewDto(TbGoods tbGoods);

    @Mapping(source = "brand", target = "goodsBrand")
    @Mapping(source = "goodsInfo", target = "goodsIntroduction")
    @Mapping(source = "minPrice", target = "lowestPrice")
    List<GoodsPreviewDto> convertTbGoodsListToGoodsPreviewDtoList(List<TbGoods> tbGoodsList);

    @Mapping(source = "brand", target = "goodsBrand")
    @Mapping(source = "goodsInfo", target = "goodsIntroduction")
    @Mapping(source = "minPrice", target = "lowestPrice")
    UserGoodsDetailsDto convertTbGoodsToGoodsDetailsDto(TbGoods tbGoods);

    TbGoods convertGoodsAddDtoToTbGoods(GoodsAddDto goodsAddDto);

    TbGoodsImage convertGoodsAddDtoToTbGoodsImage(GoodsAddDto goodsAddDto);

    @Mapping(source = "goodsInfo", target = "goodsIntroduction")
    List<SellerGoodsPreviewDto> convertTbGoodsListToSellerGoodsPreviewDtoList(List<TbGoods> tbGoodsList);

    @Mapping(source = "goodsInfo", target = "goodsIntroduction")
    SellerGoodsPreviewDto convertTbGoodsToSellerGoodsPreviewDto(TbGoods tbGoods);

    SellerGoodsDetailDto convertSellerGoodsDetailDtoToTbGoods(TbGoods tbGoods);
}
